package com.heima.behavior.controller;

import com.heima.behavior.service.CommentService;
import com.heima.model.behavior.dtos.CommentDto;
import com.heima.model.behavior.dtos.CommentLikeDto;
import com.heima.model.behavior.dtos.CommentSearchDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
public class CommentController {
    @Autowired
    CommentService commentService;
    /**
     * 保存评论
     */
    @PostMapping("/save")
    public ResponseResult saveComment(@RequestBody CommentDto dto) {
        return commentService.saveComment(dto);
    }

    /**
     * 查询评论列表
     */
    @PostMapping("/load")
    public ResponseResult loadComment(@RequestBody CommentSearchDto dto) {
        return commentService.loadComment(dto);
    }

    /**
     * 点赞评论
     */
    @PostMapping("/like")
    public ResponseResult likeComment(@RequestBody CommentLikeDto dto) {
        return commentService.likeComment(dto);
    }
}
